<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>log_in</title>
    <script type="text/javascript" src="../static/js/login.js"></script>
    <script type="text/javascript" src="../static/js/jquery-3.7.1.min.js"></script>
    <link rel="stylesheet" href="../static/css/login.css" />
</head>

<body>
    <div class="container">
        <h1>学生信息管理系统</h1>
        <h1>登录</h1>
        <form action="/tologin" method="post">
            <div class="form-control">
                <input id="username" name="username" type="text" placeholder="请输入用户名">
            </div>
            <div class="form-control">
                <input id="password" name="password" type="password" placeholder="请输入密码">
            </div>
            <input type="submit" value="登录" class="btn">
            <p class="text">您还没有账号?<a href="">注册</a></p>
        </form>
    </div>
</body>
<script>
    //登录方法,主要是拿到用户名，密码，向服务器发送请求
    function login(){
        let username = document.getElementById("username");
        let password = document.getElementById("password");
        alert(username.value + ":" + password.value);
        $.ajax({
            url:"/tologin",
            type:"post",
            data:{
                username:username,
                password:password
            },
            dataType:"json",
            success:function (e){
                console.log("success:function",e)
            },
            error:function (XHR, textStatus, errorThrown){

            }
        });
    }
</script>
</html>